Fix numpy header detection
authorStuart Prescott <stuart@debian.org>
Sat, 15 Feb 2025 14:27:09 +0000 (01:27 +1100)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 26 Feb 2026 17:00:36 +0000 (17:00 +0000)
Existing code makes assumptions about site-packages/dist-packages
and fails to find the headers; numpy has an explicit function for this

Gbp-Pq: Name 0005-Fix-numpy-header-detection.patch

build_scripts/utils.py

index eb0c8b0b673f170b77aaf603088831e982b456b4..9efbf7363d5bc5aac8e61a47a9d3132a5ad966d6 100644 (file)
@@ -77,17 +77,8 @@ def update_env_path(newpaths):
 
 
 def get_numpy_location():
-    for p in sys.path:
-        if 'site-' in p:
-            numpy = Path(p).resolve() / 'numpy'
-            if numpy.is_dir():
-                candidate = numpy / '_core' / 'include'  # Version 2
-                if not candidate.is_dir():
-                    candidate = numpy / 'core' / 'include'  # Version 1
-                if candidate.is_dir():
-                    return os.fspath(candidate)
-                log.warning(f"Cannot find numpy include dir under {numpy}")
-    return None
+    import numpy
+    return numpy.get_include()
 
 
 def platform_cmake_options(as_tuple_list=False):